package sample;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;


import javafx.scene.control.ScrollPane;

import java.awt.*;
import java.awt.image.BufferedImage;

public class Main extends Application {

    final String title = "Japhet _ 测试系统 ";
    String iconPath = "/resourse/tray.png";
    final String webUrl = "http://21r9y09161.iask.in:16706/";

    @Override
    public void start(final Stage stage) throws Exception {
        TrayUtil.initTray(stage, "Japhet _ 测试系统 ");
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        stage.setWidth(screenSize.getWidth() - 200.0D);
        stage.setHeight(screenSize.getHeight() - 200.0D);
        Scene scene = new Scene(new Group());
        WebView browser = new WebView();
        WebEngine webEngine = browser.getEngine();
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setFitToHeight(true);
        scrollPane.setFitToWidth(true);
        scrollPane.setContent(browser);
        scene.setRoot(scrollPane);
        webEngine.load("http://21r9y09161.iask.in:16706/");
//        stage.getIcons().add(new Image("/path/to/stackoverflow.jpg"));
        stage.setTitle("Japhet _ 测试系统 ");
        stage.setScene(scene);
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {
                ChooseExitType.choose(stage);
                event.consume();
            }
        });
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


